package com.hpeu_12.day1224;

import java.util.Scanner;

public class HomeWork01 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
        System.out.println("请输入年：");
        int year = scanner.nextInt();
        System.out.println("请输入月：");
        int month = scanner.nextInt();
        System.out.println("请输入日：");
        int day = scanner.nextInt();
        int sumDay=0;
        int correctDay=0;
        if(year <= 0 || (month <= 0 || month >=13) || day <= 0){ //判断该年、月、日是否合乎常理		
			System.out.println("年月日输入有误");
		}else{
			switch(month){//计算出该月正确的天数
				case 1:
				case 3:
				case 5:
				case 7:
				case 8:
				case 10:
				case 12:
					correctDay = 31;
					break;
				case 2:
					if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))//如果是闰年
						correctDay = 29;
					else
						correctDay = 28;
					break;
				case 4:
				case 6:
				case 9:
				case 11:
					correctDay = 30;
					break;
				}
			
			if(day > correctDay){ //如果用户输入的日期大于该月应有的日期，则输出提示
				System.out.println(year + "年" + month + "月没有" + day + "号,请重新输入");
			}else{
				//将每月的天数累加
				switch(month){
					case 12:
						sumDay += 30;
					case 11:
						sumDay += 31;
					case 10:
						sumDay += 30;
					case 9:
						sumDay += 31;
					case 8:
						sumDay += 31;
					case 7:
						sumDay += 30;
					case 6:
						sumDay += 31;
					case 5:
						sumDay += 30;
					case 4:
						sumDay += 31;
					case 3:
						if(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
							sumDay += 29;
						else
							sumDay += 28;
					case 2:
						sumDay += 31;
					case 1:
						sumDay += day;
				}
				System.out.println(year + "年" + month + "月" + day + "日，是" + year + "年的第" + sumDay + "天");
			}
		}
	}    
}
